const {sequelize} = require('../../core/db');
const {Sequelize, Model} = require('sequelize');

const classicFields = {
    image: Sequelize.STRING,
    content: Sequelize.STRING,
    pubdate: Sequelize.DATEONLY, // 发布的日期
    fav_nums: {
        type: Sequelize.INTEGER,
        default: 0
    }, // 点赞数目
    title: Sequelize.STRING, // 标题
    type: Sequelize.SMALLINT // 模型
}

// 电影
class Movie extends Model {

}

Movie.init(classicFields, {
    sequelize,
    tableName: 'movie'
})


class Sentence extends Model {

}

Sentence.init(classicFields, {
    sequelize,
    tableName: 'sentence'
})


// 音乐
class Music extends Model {
}

// 增加一个音乐连接
const musicFields = Object.assign({url: Sequelize.STRING}, classicFields)
Music.init(musicFields, {
    sequelize,
    tableName: 'music'
})

/**
 * 关联
 * type: 100 Movie
 * type: 200 Music
 * type: 300 Sentence
 */


module.exports = {
    Movie,
    Sentence,
    Music
}